use "cv21m_EN_1.0p.dta", replace 
*------------------*	   
* Data preparation *
*------------------*	
********************
* gen day variable *
********************
fre cv21m293
gen date_p2 = date(cv21m293, "DMY")
format date_p2 %td
tab date_p2, m

gen day = date_p2 - td(6jan2021) 
fre day 
drop if date_p2==td(6jan2021) 

egen day_5 = cut(day), at(1(5)55) // 5 days in a bin
tab day day_5, m 
replace day_5=0 if day<0
tab day day_5, m 
fre day_5
recode day_5 (6=2) (11=3) (16=4) (26/46=5) // 0= day-1 to -2; 1= day 1-5; 2= day 6-10 and so on
fre day_5

*******************
* treatment group *
*******************
label define lbgr 0"Pre-Jan 6th" 1"Post-Jan 6th" 
gen tr=.
replace tr=0 if date_p2<td(6Jan2021)
replace tr=1 if date_p2>td(6Jan2021) 
label values tr lbgr
tab tr, m 

******************
* clean outcomes * 
******************
*****************************
* expressed vote preference *
*****************************
* Far-right 
gen fr=.
replace fr=1 if cv21m308==3 | cv21m308==14 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr=0 if cv21m308!=3 & cv21m308!=14 & cv21m308!=.
replace fr=. if cv21m308==1 | cv21m308==15 | cv21m308==-8 | cv21m308==-9  //1.[if cv21m243=0: I would not vote]; 15 Blank; -9 I don’t know; -8 I prefer not to say
fre fr

* Far-right (with missing: would not vote; Blank vote; don't know; prefer not to say are coded as 0)
gen fr_m=.
replace fr_m=1 if cv21m308==3 | cv21m308==14 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr_m=0 if cv21m308!=3 & cv21m308!=14 & cv21m308!=.
replace fr_m=0 if cv21m308==1 | cv21m308==15 | cv21m308==-8 | cv21m308==-9  //1.[if cv21m243=0: I would not vote]; 15 Blank; -9 I don’t know; -8 I prefer not to say
fre fr_m

* radical left 
gen fl=.
replace fl=1 if cv21m308==6 | cv21m308==7 | cv21m308==10 //6. GroenLinks (green party); 7. SP (socialist party); 10. Partij voor de Dieren (animal welfare party)
replace fl=0 if cv21m308!=6 & cv21m308!=7 & cv21m308!=10 & cv21m308!=.
replace fl=. if cv21m308==1 | cv21m308==15 | cv21m308==-8 | cv21m308==-9 

* Incumbent party
fre cv21m308
gen govt=. 
replace govt=1 if cv21m308==2 | cv21m308==4 | cv21m308==5 | cv21m308==9 // 2. VVD (liberal party); 4. CDA (Christian democrat party); 5. D66 (social-liberal party) 9.ChristenUnie (Christian union party)
replace govt=0 if cv21m308!=2 & cv21m308!=4 & cv21m308!=5 & cv21m308!=9 & cv21m308!=.
replace govt=. if cv21m308==1 | cv21m308==15 | cv21m308==-8 | cv21m308==-9 

* recall vote (far-right)
fre cv21m307
gen recall_fr=.
replace recall_fr=1 if cv21m307==2 | cv21m307==13
replace recall_fr=0 if cv21m307!=2 & cv21m307!=13 & cv21m307!=.
replace recall_fr=. if cv21m307==-8 | cv21m307==-9 | cv21m307==14 // -8 I prefer not to say; -9 I don’t know; 14 Blank vote

*****************************
* Left-right self-placement *
*****************************
fre cv21m101
replace cv21m101=. if cv21m101==-9
clonevar lr_self=cv21m101

***************************
* Confidence in democracy *
***************************
fre cv21m027
replace cv21m027=. if  cv21m027==-9
clonevar demo=cv21m027

**************
* Covariates * 
**************
* merging with the demographic variables dataset
merge 1:1 nomem_encr using "avars_202101_EN_1.0p.dta"
keep if _merge==3

fre geslacht // Gender
rename geslacht gender 

fre leeftijd //Age of the household member
rename leeftijd age
label var age "Age"

fre burgstat //Civil status
* recode burgstat 
rename burgstat civil
recode civil (3=2) (4=3) (5=4)
label define lbcivil 1"Married" 2"Separated/Divorced" 3"Widow or widower" 4"Never been married" 
label values civil lbcivil
fre civil
	
fre oplcat // Level of education in CBS (Statistics Netherlands) categories
rename oplcat edu
label define lbedu 1"Primary school" 2"Intermediate secondary education" ///
	3"Higher secondary education/preparatory university education" 4"Intermediate vocational education" ///
	5"Higher vocational education" 6"University"	
label values edu lbedu


fre nettocat // Personal net monthly income in categories
replace nettocat=. if nettocat==13 | nettocat==14
rename nettocat income 
label var income "Personal net monthly income"

fre sted // Urban character of place of residence
rename sted urban

fre herkomstgroep //Origin
gen origin=.
replace origin=0 if herkomstgroep==0
replace origin=1 if herkomstgroep==101 | herkomstgroep==102 | herkomstgroep==201 | herkomstgroep==202
label define lborigin 0"Dutch" 1"non-Dutch" 
label values origin lborigin


***************************
* creating entropy weight *
***************************
ebalance tr age i.gender i.civil i.edu income i.urban i.origin, tar(2)

******************************
* check sample in regression *
******************************
fre tr if fr_m!=.


**********************************************
* Incorporating previous and subsequent wave *
**********************************************
fre wave
replace wave=13
append using "cv22n_EN_1.0p.dta"
fre wave
replace wave=14 if wave==.
append using "cv20l_EN_1.0p.dta"
fre wave
replace wave=12 if wave==.
tsset nomem_encr wave  

fre cv20l293
replace date_p2 = date(cv20l293, "DMY") if wave==12 & date_p2==.
format date_p2 %td
tab date_p2 if wave==12, m

fre cv22n293
replace date_p2 = date(cv22n293, "YMD") if wave==14
format date_p2 %td
tab date_p2 if wave==14, m

*****************************
* expressed vote preference *
*****************************
* far right 
* wave 12
replace fr=1 if (cv20l308==3 | cv20l308==14) & fr==. & wave==12 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr=0 if cv20l308!=3 & cv20l308!=14 & cv20l308!=. & fr==. & wave==12 
replace fr=. if (cv20l308==1 | cv20l308==15 | cv20l308==-8 | cv20l308==-9) & wave==12  // 1 I would not vote; 15 Blank; -9 I don't know; -8 I prefer not to say
fre fr if wave==12

* wave 14
replace fr=1 if (cv22n308==3 | cv22n308==14) & fr==. & wave==14 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr=0 if cv22n308!=3 & cv22n308!=14 & cv22n308!=. & fr==. & wave==14 
replace fr=. if (cv22n308==1 | cv22n308==15 | cv22n308==-8 | cv22n308==-9) & wave==14  // 1 I would not vote; 15 Blank; -9 I don't know; -8 I prefer not to say
fre fr if wave==14

* far right (would not vote; Blank vote; don't know; prefer not to say are coded as 0)
* wave 12
replace fr_m=1 if (cv20l308==3 | cv20l308==14) & fr_m==. & wave==12 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr_m=0 if cv20l308!=3 & cv20l308!=14 & cv20l308!=. & fr_m==. & wave==12
replace fr_m=0 if (cv20l308==1 | cv20l308==15 | cv20l308==-8 | cv20l308==-9) & wave==12  // 1 I would not vote; 15 Blank; -9 I don't know; -8 I prefer not to say
fre fr_m if wave==12

* wave 14
replace fr_m=1 if (cv22n308==3 | cv22n308==14) & fr_m==. & wave==14 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr_m=0 if cv22n308!=3 & cv22n308!=14 & cv22n308!=. & fr_m==. & wave==14
replace fr_m=0 if (cv22n308==1 | cv22n308==15 | cv22n308==-8 | cv22n308==-9) & wave==14  // 1 I would not vote; 15 Blank; -9 I don't know; -8 I prefer not to say
fre fr_m if wave==14

**********************************************
* restructuring the panel dataset's variable *
**********************************************
* treatment dummy
bysort nomem_encr: mipolate tr wave, gen(tr2)  groupwise
drop tr
rename tr2 tr
label values tr lbgr
tab tr, m 

* entropy weight
bysort nomem_encr: mipolate _webal wave, gen(_webal2)  groupwise
drop _webal
rename _webal2 ebal_main

* checking distribution of voters over waves
tab fr wave, m
tab fr_m wave, m  

* respondents who are present in all 3 waves
gen wave12 = wave==12
gen wave13 = wave==13
gen wave14 = wave==14
bysort nomem_encr: egen n_waves_3 = total(wave12+wave13+wave14)
tab n_waves_3 
save "liss_trend.dta", replace 


*-------------------------*	 
* Covariate balance tests *
*-------------------------*	 
use "liss_trend.dta", replace 
set scheme white_ptol
eststo age: reg tr age if wave==13 // treatment group is slightly younger
eststo gender: reg tr i.gender if wave==13 // treatment group is more likely to be female
forvalues i=1/4{
	eststo civil`i': reg tr `i'.civil  if wave==13
}

forvalues i=1/6{
	eststo edu`i': reg tr `i'.edu  if wave==13
}

eststo income: reg tr income if wave==13 // n.s.
forvalues i=1/5{
	eststo urban`i': reg tr `i'.urban if wave==13 // n.s.
}
eststo origin: reg tr i.origin if wave==13 // treatment group is more likely to be non-Dutch


coefplot age gender civil1 civil2 civil3 civil4 edu1 edu2 edu3 edu4 edu5 edu6 income urban1 urban2 urban3 urban4 urban5 origin  , ///
	drop(_cons) xtitle("Estimate") xline(0, lpattern(l)) legend(off) mcolor(black)  ciopts(lcolor(black)) offset(0) ///
	mlabel format(%9.2g) mlabposition(11) mlabgap(*0.5) ///
	headings(age="{bf:Age}" 2.gender="{bf:Gender}" 1.civil="{bf:Civil status}" 1.edu="{bf:Education level}" ///
	income="{bf:Income}" 1.urban="{bf:Place of residence}" 1.origin="{bf:Respondent’s origin}")
graph export "cov_balance.png", as(png) replace 

*-----------------------------------------------------------------*	   
* Main analysis: reducing expressed support for far-right parties * 
*-----------------------------------------------------------------*	   
********************
* Treatment effect *
********************
svyset [pweight= ebal_main]
eststo fr_pr: svy: reg fr i.tr if wave==13
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a) ", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fr_pr, replace) scheme(538bw)
coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///AME of Jan 6th
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
   saving(fr_dydx, replace) scheme(538bw)
graph combine fr_pr.gph fr_dydx.gph
graph export "fr_pr+dydx.png", replace

* binning tr into 5 days
eststo fr_pr_temporal: svy: reg fr i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c) ", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fr_pr_temporal, replace) scheme(538bw)
coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30) ) ///
saving(fr_temporal_dydx, replace) scheme(538bw)
graph combine fr_pr.gph fr_dydx.gph fr_pr_temporal.gph fr_temporal_dydx.gph, row(2) 
graph export "fr_full.png", replace

* regression table
esttab  fr_pr fr_pr_temporal using "fr_pr_main.rtf", b(2) se(2) replace ///
	scalars("N Observations"  "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	coeflabel(1.day_5 "Day 1 to 5" 2.day_5 "Day 6 to 10" 3.day_5 "Day 11 to 15" 4.day_5 "Day 16 to 20" 5.day_5 "Day>20") ///
	mtitles("(1) " "(2) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.2. Effect of Capitol insurrection on the expressed support for the domestic far-right party") 


	
*********************************************************************
* Parallel trend assumption, manipulation check, effect persistence *
*********************************************************************
eststo fr_trend: svy: reg fr tr##i.wave if n_waves_3==3
test 13.wave#1.tr + 1.tr= 13.wave#0.tr // main treatment effect
test 14.wave#1.tr + 1.tr= 14.wave#0.tr // manipulation check
margins wave, at(tr=(0 1)) 
mplotoffset, xdim(wave) xtitle("") ///
	xlabel(12 `" "Wave 12" "(6/1/2020 to 25/2/2020)""' 13 `" "Wave 13" "(4/1/2021 to 23/2/2021)""' 14 `" "Wave 14" "(3/1/2022 to 28/2/2022)""') ///
	plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(lcolor(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	ytitle("Pr(voting a far right party)", size(medium)) ylabel(0.08(0.04)0.20) legend(position(6) col(2) order(3 "Control group" 4 "Treatment group")) /// 
	title(" ")  saving(fr_trend,replace) scheme(538bw) plotregion(margin(vlarge))
graph export "fr_trend.png",  as(png) replace

* regression table
esttab  fr_trend using "fr_trend.rtf", b(2) se(2) replace ///
	scalars("N Observations"  "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(25) ///
	coeflabel(1.tr "Treatment" 13.wave "wave 13"  14.wave "wave 14" 1.tr#13.wave "Treatment # wave 13" 1.tr#14.wave "Treatment # wave 14") ///
	mtitles("(1) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.3. Comparing the predicted probability of expressing support for a far-right party across waves (Control group vs. Treatment group in Wave 13)") 


*-------------------*	   
* Robustness checks *
*-------------------*	   
*****************************
* Without entropy weighting *
*****************************
eststo fr_pr_noeb: reg fr i.tr if wave==13 
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)
combomarginsplot trx tr1,  ///
	title("        (a) ", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fr_pr_noeb, replace) scheme(538bw)
coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///AME of Jan 6th
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
   saving(fr_dydx_noeb, replace) scheme(538bw)

   
* binning tr into 5 days
eststo fr_pr_temporal_noeb: reg fr i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c) ", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fr_pr_temporal_noeb, replace) scheme(538bw)
coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30) ) ///
saving(fr_temporal_dydx_noeb, replace) scheme(538bw)
graph combine fr_pr_noeb.gph fr_dydx_noeb.gph fr_pr_temporal_noeb.gph fr_temporal_dydx_noeb.gph, row(2) 
graph export "fr_noeb.png", replace   
   
****************************************************
* Entropy balancing for unbalanced covariates only *
****************************************************
ebalance tr age i.gender i.origin, tar(2)
svyset [pweight= _webal]
eststo fr_pr_ebv2: svy: reg fr i.tr if wave==13
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)
combomarginsplot trx tr1,  ///
	title("        (a) ", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fr_pr_ebv2, replace) scheme(538bw)
coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///AME of Jan 6th
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
   saving(fr_dydx_ebv2, replace) scheme(538bw)

* binning tr into 5 days
eststo fr_pr_temporal_ebv2: svy: reg fr i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c) ", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fr_pr_temporal_ebv2, replace) scheme(538bw)
coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30) ) ///
saving(fr_temporal_dydx_ebv2, replace) scheme(538bw)
graph combine fr_pr_ebv2.gph fr_dydx_ebv2.gph fr_pr_temporal_ebv2.gph fr_temporal_dydx_ebv2.gph, row(2) 
graph export "fr_ebv2.png", replace      
   

* regression table
esttab  fr_pr_noeb fr_pr_temporal_noeb fr_pr_ebv2 fr_pr_temporal_ebv2  using "fr_pr_other_eb.rtf", b(2) se(2) replace ///
	scalars("N Observations"  "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	keep (1.tr 1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) ///
	mtitles("(1) Without entropy weight " "(2) Without entropy weight" "(3) Entropy balancing using only imbalanced covariates"  "(4) Entropy balancing using only imbalanced covariates") modelwidth(7) ///
	coeflabel(1.day_5 "Day 1 to 5" 2.day_5 "Day 6 to 10" 3.day_5 "Day 11 to 15" 4.day_5 "Day 16 to 20" 5.day_5 "Day>20") ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Model 1 does not include any entropy weighting. Model 2 uses entropy weight that is created based on imbalanced covariates only (i.e. age, gender, and respondent's origin). The moment is set to the variance of each covariate.") ///
	title("Table B.4. Other model specifications: without entropy weight, and entropy weight created by imbalanced covariates only") 

drop _webal
	
*********
* logit *
*********
svyset [pweight= ebal_main]
eststo logit_fr_pr: svy: logit fr i.tr if wave==13 
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a)", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fr_pr, replace) scheme(538bw)
coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b) ", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-1.2(0.2)0.2)  ///
   saving(fr_dydx, replace) scheme(538bw)

* binning tr into 5 days
eststo logit_fr_pr_temporal: svy: logit fr i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c)", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fr_pr_temporal, replace) scheme(538bw)
coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-1.2(0.2)0.2) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30) ) ///
saving(fr_temporal_dydx, replace) scheme(538bw)

graph combine fr_pr.gph fr_dydx.gph fr_pr_temporal.gph fr_temporal_dydx.gph, row(2)
graph export "fr_logit.png", replace

* regression table
esttab  logit_fr_pr logit_fr_pr_temporal using "logit_fr_pr.rtf", b(2) se(2) replace ///
	scalars("N Observations") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	coeflabel(1.day_5 "Day 1 to 5" 2.day_5 "Day 6 to 10" 3.day_5 "Day 11 to 15" 4.day_5 "Day 16 to 20" 5.day_5 "Day>20") ///
	mtitles("(1) " "(2) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of logit regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.5. Other model specification: Logit regression") 

*********************
* Placebo: far-left *
*********************
eststo fl_pr: svy: reg fl i.tr if wave==13 
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a)", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-left party)", size(medium)) ylab(0.1(0.1)0.4) ///
	plotopt(connect(none)) plot1opts(lcolor(plr2) mcolor(plr2) msymbol(Oh) msize(medium)) ci1opts(color(plr2)) ///
	plot2opts(lcolor("219 15 39") mcolor("219 15 39") msymbol(T) msize(large)) ci2opts(lcolor("219 15 39")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fl_pr, replace) scheme(538bw)	   

coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.1(0.1)0.2) ///
   saving(fl_dydx, replace) scheme(538bw)

* temporal
eststo fl_pr_temporal: svy: reg fl i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c)", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-left party)", size(medium)) ylab(0.1(0.1)0.4) ///
	plotopt(connect(none)) plot1opts(lcolor(plr2) mcolor(plr2) msymbol(Oh) msize(medium)) ci1opts(color(plr2)) ///
	plot2opts(lcolor("219 15 39") mcolor("219 15 39") msymbol(T) msize(large)) ci2opts(lcolor("219 15 39")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fl_pr_temporal, replace) scheme(538bw)

coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.1(0.1)0.2)  ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20" ) ///
saving(fl_temporal_dydx, replace) scheme(538bw)
graph combine fl_pr.gph fl_dydx.gph fl_pr_temporal.gph fl_temporal_dydx.gph, row(2)
graph export "fl_full.png", replace

****************************
* Placebo: incumbent party *
****************************
eststo govt_pr: svy: reg govt i.tr if wave==13 // n.s.
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a)", size(medium) ///
	pos(11)) ytitle("Pr(Voting an incumbent party)", size(medium)) ylab(0.3(0.1)0.6) ///
	plotopt(connect(none)) plot1opts(lcolor(sea) mcolor(sea) msymbol(Oh) msize(medium)) ci1opts(color(sea)) ///
	plot2opts(lcolor("0 48 143") mcolor("0 48 143") msymbol(T) msize(large)) ci2opts(lcolor("0 48 143")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(govt_pr, replace) scheme(538bw)

coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.2(0.1)0.1) ///
   saving(govt_dydx, replace) scheme(538bw)

* temporal
eststo govt_pr_temporal: svy: reg govt i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c)", size(medium) pos(11)) ///
	ytitle("Pr(Voting an incumbent party)", size(medium)) ylab(0.3(0.1)0.6) ///
	plotopt(connect(none)) plot1opts(lcolor(sea) mcolor(sea) msymbol(Oh) msize(medium)) ci1opts(color(sea)) ///
	plot2opts(lcolor("0 48 143") mcolor("0 48 143") msymbol(T) msize(large)) ci2opts(lcolor("0 48 143")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(govt_pr_temporal, replace) scheme(538bw)

coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.2(0.1)0.1)   ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20" ) ///
saving(govt_temporal_dydx, replace) scheme(538bw)
graph combine govt_pr.gph govt_dydx.gph govt_pr_temporal.gph govt_temporal_dydx.gph, row(2)
graph export "govt_full.png", replace

* regression table
esttab fl_pr fl_pr_temporal govt_pr govt_pr_temporal using "placebo.rtf", b(2) se(2) replace ///
	scalars("N Observations" "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	coeflabel(1.day_5 "Day 1 to 5" 2.day_5 "Day 6 to 10" 3.day_5 "Day 11 to 15" 4.day_5 "Day 16 to 20" 5.day_5 "Day>20") ///
	mtitles("(1) Far-left party " "(2) Far-left party" "(3) Incumbent party " "(4) Incumbent party") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: In Models 1 and 2, the dependent variable is expressed support for a far-left party. In Models 3 and 4, the dependent variable is expressed support for an incumbent party. Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.6. Placebo tests: Changing DV to expressed support for a far-left party or an incumbent party") 	
	
*********************************
* Far-right vote (with missing) *
*********************************
eststo fr_m_pr: svy: reg fr_m i.tr if wave==13
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a)", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th" 1 "Post-Jan 6th") ///
	legend(off) saving(fr_m_pr, replace) scheme(538bw)
coefplot, keep(1.tr) yline(0) msymbol(s) mfcolor(white)    ///AME of Jan 6th
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
   saving(fr_m_dydx, replace) scheme(538bw)

eststo fr_m_pr_temporal: svy: reg fr_m i.day_5 if wave==13
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c)", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.2) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -2" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(fr_m_pr_temporal, replace) scheme(538bw)
coefplot,  keep(1.day_5 2.day_5 3.day_5 4.day_5 5.day_5) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d)", size(medium) pos(11)) ytitle("Coefficient estimate", size(medium)) ylab(-0.15(0.05)0.05) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30) ) ///
saving(fr_m_temporal_dydx, replace) scheme(538bw)
graph combine fr_m_pr.gph fr_m_dydx.gph fr_m_pr_temporal.gph fr_m_temporal_dydx.gph, row(2)
graph export "fr_m_full.png", replace

* regression table
esttab  fr_m_pr fr_m_pr_temporal using "fr_m_pr.rtf", b(2) se(2) replace ///
	scalars("N Observations" "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	coeflabel(1.day_5 "Day 1 to 5" 2.day_5 "Day 6 to 10" 3.day_5 "Day 11 to 15" 4.day_5 "Day 16 to 20" 5.day_5 "Day>20") ///
	mtitles("(1) " "(2) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.7. Including respondents who do not express vote preference") 

************************************************************************************
* Parallel trend assumption, manipulation check, effect persistence (with missing) *
************************************************************************************	
eststo fr_m_trend: svy: reg fr_m tr##i.wave 
test 13.wave#1.tr + 1.tr= 13.wave#0.tr
test 14.wave#1.tr + 1.tr= 14.wave#0.tr

margins wave, at(tr=(0 1)) 
mplotoffset, xdim(wave) xtitle("") ///
	xlabel(12 `" "Wave 12" "(6/1/2020 to 25/2/2020)""' 13 `" "Wave 13" "(4/1/2021 to 23/2/2021)""' 14 `" "Wave 14" "(3/1/2022 to 28/2/2022)""') ///
	plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(lcolor(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	ytitle("Pr(voting a far right party)") ylabel(0.04(0.04)0.16) legend(position(6) col(2) order(3 "Control group" 4 "Treatment group")) /// 
	title("", size(medsmall))  saving(fr_m_trend,replace) scheme(538bw) plotregion(margin(vlarge))
graph export "fr_m_trend.png",  as(png) replace	


* regression table
esttab  fr_m_trend using "fr_m_trend.rtf", b(2) se(2) replace ///
	scalars("N Observations"  "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(25) ///
	coeflabel(1.tr "Treatment" 13.wave "wave 13"  14.wave "wave 14" 1.tr#13.wave "Treatment # wave 13" 1.tr#14.wave "Treatment # wave 14") ///
	mtitles("(1) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Respondents who answer (i) abstention, (ii) casting a blank vote, (iii) I don't know, or (iv) I prefer not to say are included and coded as zero. Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.8. Replicating Table B.4 by including missing answers of expressed vote preference") 


*******************************
* pseudo-treatment: year 2018 *
*******************************
use "cv18j_EN_1.0p.dta", replace 
* check dates 
fre cv18j293
gen date_p2_pcbo = date(cv18j293, "DMY")
format date_p2_pcbo %td
tab date_p2_pcbo, m

* gen day variable 
gen day_pcbo = date_p2_pcbo - td(6jan2018) 
fre day_pcbo 
drop if date_p2_pcbo==td(6jan2018) 

egen day_5_pcbo = cut(day_pcbo), at(1(5)60) // 5 days in a bin
replace day_5_pcbo=0 if day_pcbo<0
tab day_pcbo day_5_pcbo, m 
fre day_5_pcbo
recode day_5_pcbo (6=2) (11=3) (16=4) (21/60=5)  // 0= day-1 to -2; 1= day 1-5; 2= day 6-10 and so on
fre day_5_pcbo
tab day_pcbo day_5_pcbo


* tr group 
label define lbgr_pcbo 0"Pre-Jan 6th in 2018" 1"Post-Jan 6th in 2018" 
gen tr_pcbo=.
replace tr_pcbo=0 if date_p2_pcbo<td(6Jan2018)
replace tr_pcbo=1 if date_p2_pcbo>td(6Jan2018) 
label values tr_pcbo lbgr_pcbo
tab tr_pcbo, m


* far right 
fre cv18j308
gen fr_pcbo=.
replace fr_pcbo=1 if cv18j308==3 | cv18j308==14 // 3. PVV (Wilders freedom party); 14. Forum voor Democratie (Party for Democracy)
replace fr_pcbo=0 if cv18j308!=3 & cv18j308!=14 & cv18j308!=.
replace fr_pcbo=. if cv18j308==1 | cv18j308==15 | cv18j308==998 | cv18j308==999  //1.[if cv18j243=0: I would not vote]; 15 Blank; 998 I prefer not to say; 999 I dont know
fre fr_pcbo

* merging with the demographic variables dataset
merge 1:1 nomem_encr using "avars_202101_EN_1.0p.dta"
keep if _merge==3

fre geslacht // Gender
rename geslacht gender 

fre leeftijd //Age of the household member
rename leeftijd age

fre burgstat //Civil status
//recode burgstat 
rename burgstat civil


fre oplcat // Level of education in CBS (Statistics Netherlands) categories
rename oplcat edu

fre nettocat // Personal net monthly income in categories
replace nettocat=. if nettocat==13 | nettocat==14
rename nettocat income 

fre sted // Urban character of place of residence
rename sted urban

fre herkomstgroep //Origin
gen origin=.
replace origin=0 if herkomstgroep==0
replace origin=1 if herkomstgroep==101 | herkomstgroep==102 | herkomstgroep==201 | herkomstgroep==202
label define lborigin 0"Dutch" 1"non-Dutch" 
label values origin lborigin

* entropy balancing
ebalance tr age i.gender i.civil i.edu income i.urban i.origin, tar(2)
svyset [pweight= _webal]

* 
eststo fr_pr_2018: svy: reg fr_pcbo i.tr_pcbo
margins tr if tr==0|tr==1, saving(trx ,replace)
margins tr if tr==1, saving(tr1 ,replace)

combomarginsplot trx tr1,  ///
	title("        (a)", size(medium) ///
	pos(11)) ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.25) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(-0.5 " " 1.5 " " 0 "Pre-Jan 6th in 2018" 1 "Post-Jan 6th in 2018") ///
	legend(off) saving(2018_fr_pr, replace) scheme(538bw)
coefplot, keep(1.tr_pcbo) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(b)", size(medium) pos(11)) ytitle("AME of Jan 6th") ylab(-0.15(0.05)0.1) ///
   saving(2018_fr_dydx, replace) scheme(538bw)

eststo fr_pr_temporal_2018: svy: reg fr i.day_5_pcbo
margins day_5 if day_5==0 | day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(trx ,replace)
margins day_5 if  day_5==1 | day_5==2 | day_5==3 | day_5==4 | day_5==5, saving(tr1 ,replace)

combomarginsplot trx tr1, labels() ///
	title("        (c)", size(medium) pos(11)) ///
	ytitle("Pr(Voting a far-right party)", size(medium)) ylab(0(0.05)0.25) ///
	plotopt(connect(none)) plot1opts(lcolor(pll1) mcolor(pll1) msymbol(Oh) msize(medium)) ci1opts(color(pll1)) ///
	plot2opts(lcolor("78 42 132") mcolor("78 42 132") msymbol(T) msize(large)) ci2opts(lcolor("78 42 132")) ///
	xtitle("") xlab(0 "Day -1 to -5" 1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 ">Day 20", angle(30)) ///
	legend(off) saving(2018_fr_pr_temporal, replace) scheme(538bw)
coefplot,  keep(1.day_5_pcbo 2.day_5_pcbo 3.day_5_pcbo 4.day_5_pcbo 5.day_5_pcbo 6.day_5_pcbo) yline(0) msymbol(s) mfcolor(white)    ///
   levels(95 90)  ciopts(lwidth(*1 *3)) vertical  title("(d)", size(medium) pos(11)) ytitle("AME of Jan 6th") ylab(-0.15(0.05)0.1) ///
xlab(1 "Day 1 to 5" 2 "Day 6 to 10" 3 "Day 11 to 15" 4 "Day 16 to 20" 5 "Day>20", angle(30)) ///
saving(2018_fr_temporal, replace) scheme(538bw)
graph combine 2018_fr_pr.gph 2018_fr_dydx.gph 2018_fr_pr_temporal.gph 2018_fr_temporal.gph, row(2)
graph export "2018_fr_full.png", replace

* regression table
esttab  fr_pr_2018 fr_pr_temporal_2018 using "2018_fr_pr.rtf", b(2) se(2) replace ///
	scalars("N Observations" "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	coeflabel(1.day_5_pcbo "Day 1 to 5" 2.day_5_pcbo "Day 6 to 10" 3.day_5_pcbo "Day 11 to 15" 4.day_5_pcbo "Day 16 to 20" 5.day_5_pcbo "Day>20") ///
	mtitles("(1) " "(2) ") modelwidth(7) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.9. Using 2018 LISS dataset as pseudo-treatment") 

	
*---------------------*
* Additional analysis *
*---------------------*
use "liss_trend.dta", replace 
set scheme white_ptol  
svyset [pweight= ebal_main]

* left/right placement
eststo lr_self: svy: reg lr_self i.tr if wave==13
   
* confidence in democratic institutions
eststo demo: svy: reg demo i.tr if wave==13

* recall vote
eststo recall_fr_pr: svy: reg recall_fr i.tr if wave==13 

* regression table
esttab lr_self demo recall_fr_pr using "lr+swd+recall.rtf", b(2) se(2) replace /// 
	scalars("N Observations"  "r2 R-squared") ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(15) ///
	mtitles("(1) Left/right self-placement" "(2) Confidence in democratic institutions" "(3) Recall vote for far-right parties") modelwidth(12) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are coefficients of OLS regression. Standard errors are shown in parentheses. Entropy weight is created based on observable covariates, including age, gender, civil status, education level, income, urban character of the place of residence, and respondent's origin. The moment is set to the variance of each covariate.") ///
	title("Table B.10. Effect of Capitol insurrection on left/right self-placement, confidence in democratic institutions, and recall vote") 
